<template>
<div>
  <van-nav-bar title="个人中心"/>
  <div style="background-color: dodgerblue">
    <van-row justify="left">
      <van-col span="4" offset="2">
        <van-image
            round
            width="3rem"
            height="3rem"
            src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
            style="margin: 1rem"
        />
      </van-col>
      <van-col span="12" style="text-align: left;padding-left: 1rem;color: white">
        <div style="margin-top: 1rem;font-size: 1.2rem">邢朋辉</div>
        <div>185****0152</div>
      </van-col>
      <van-col span="6">
        <van-icon style="margin: 2rem" name="chat-o" badge="10+" />
      </van-col>
    </van-row>

  <div style="width: 80%;margin-left: 10%;box-shadow: 0 15px 30px dodgerblue;border-radius: 10px;">
    <van-grid column-num="2" style="border-radius: 20px;">
      <van-grid-item text="就诊人管理" @click="tz('/patientlist')">
        <template #icon>
          <van-image
              round
              width="3rem"
              height="3rem"
              src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
          />
        </template>
      </van-grid-item>
      <van-grid-item  text="住院人管理" @click="tz('/hospitalizedlist')">
        <template #icon>
          <van-image
              round
              width="3rem"
              height="3rem"
              src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
          />
        </template>
      </van-grid-item>
    </van-grid>
  </div>
  </div>
  <div style="margin-top: 20px;">
    <van-cell-group inset>
      <van-cell class="vc1" size="large" icon="todo-list-o" title="预约挂号" is-link />
      <van-cell class="vc1" icon="todo-list-o" title="预约挂号" is-link />
      <van-cell class="vc1" icon="todo-list-o" title="预约挂号" is-link />
      <van-cell class="vc1" icon="todo-list-o" title="预约挂号" is-link />
      <van-cell class="vc1" icon="todo-list-o" title="预约挂号" is-link />
    </van-cell-group>
  </div>
  <div style="margin-top: 3rem">
    <van-button round type="danger" block @click="loginout">注销登录</van-button>
  </div>
</div>
</template>

<script setup>
import {ref,onMounted} from 'vue'
import {useStore} from "vuex";
import {useRouter} from "vue-router";
import axios from "axios";
const store = useStore();
const router=useRouter()
const logs=new ref([])
const loginout = () => {
  //注销
  axios.get("user/logout").then(res=>{
    router.push("/login");
  })
}
onMounted(()=>{
  axios.get("user/detail").then(res=>{
    if(res.data.code==0){
      store.commit("setUser",res.data.data);
    }else {
      router.push("/login")
    }

  })
})
const tz=(url)=>{
  router.push(url);
}
</script>

<style scoped>
.vc1{
  padding: 10px;
  margin: 30px;
}
</style>
